﻿@model Weapsy.Apps.Text.Domain.Commands.AddVersion

<script>
    $(document).ready(function () {
        tinymce.remove();
        tinymce.init({
            selector: 'textarea',
            height: 350,
            theme: 'modern',
            plugins: [
              'advlist autolink lists link image charmap print preview hr anchor pagebreak',
              'searchreplace wordcount visualblocks visualchars code fullscreen',
              'insertdatetime media nonbreaking save table contextmenu directionality',
              'emoticons template paste textcolor colorpicker textpattern imagetools'
            ],
            toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
            toolbar2: 'print preview media | forecolor backcolor emoticons',
            image_advtab: true,
            templates: [
              { title: 'Test template 1', content: 'Test 1' },
              { title: 'Test template 2', content: 'Test 2' }
            ],
            content_css: [
              '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
              '//www.tinymce.com/css/codepen.min.css'
            ]
        });
    });
</script>

<form id="textModuleForm" name="textModuleForm" data-ajax="true" data-ajax-method="PUT" data-ajax-url="/Weapsy.Apps.Text/Home/Save" data-ajax-loading="#savingText" data-ajax-success="weapsy.controlPanel.refresh" class="form-horizontal validate-form" role="form">
    <input type="hidden" id="id" name="id" value="@Model.Id" />
    <input type="hidden" id="moduleId" name="moduleId" value="@Model.ModuleId" />
    <input type="hidden" id="status" name="status" value="2" />
    <ul class="nav nav-tabs">
        <li class="active">
            <a href="#Default" data-toggle="tab">Default</a>
        </li>
        @foreach (var versionLocalisation in Model.VersionLocalisations)
        {
            <li>
                <a href="#@versionLocalisation.LanguageName" data-toggle="tab">@versionLocalisation.LanguageName</a>
            </li>
        }
    </ul>
    <div class="tab-content" style="margin-top:25px;">
        <div id="Default" class="tab-pane active">
            <div class="form-group has-feedback">
                <div class="col-md-12">
                    <textarea asp-for="Content" rows="10" class="form-control validate-content" placeholder="Enter Content">@Model.Content</textarea>
                    <i class="form-control-feedback glyphicon"></i>
                </div>
                <div class="col-md-12 help-block">
                    <span asp-validation-for="Content" class="text-danger"></span>
                </div>
            </div>
        </div>
        @for (int i = 0; i < Model.VersionLocalisations.Count; i++)
        {
            <input asp-for="VersionLocalisations[i].LanguageId" type="hidden" />
            <div id="@Model.VersionLocalisations[i].LanguageName" class="tab-pane">
                <div class="form-group has-feedback">
                    <div class="col-md-12">
                        <textarea asp-for="VersionLocalisations[i].Content" rows="10" class="form-control validate-content" placeholder="Enter Content"></textarea>
                        <i class="form-control-feedback glyphicon"></i>
                    </div>
                    <div class="col-md-12 help-block">
                        <span asp-validation-for="VersionLocalisations[i].Content" class="text-danger"></span>
                    </div>
                </div>
            </div>
        }
    </div>
    @*<div class="form-group has-feedback">
        <label for="description" class="col-md-12">Description</label>
        <div class="col-md-12">
            <input type="text" id="description" name="description" class="form-control validate-description" placeholder="Enter Description" value="@Model.Description" />
            <i class="form-control-feedback glyphicon"></i>
        </div>
        <div class="col-md-12 help-block">
            <label id="description-error" for="description" class="text-danger" style="display:none;"></label>
        </div>
    </div>*@
    @*<div class="form-group">
        <div class="col-md-12">
            <input type="radio" id="statusDraft" name="status" value="1" />Save as Draft
            <input type="radio" id="statusPublished" name="status" value="2" checked="checked" />Publish Now
        </div>
    </div>*@
    <div class="form-group">
        <div class="col-md-12">
            <button id="save" type="submit" class="btn btn-primary" title="Save">Save</button>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <span id="savingText" style="display:none;">
                Saving...
            </span>
        </div>
    </div>
</form>